package com.itheima.examination2;

import java.time.Duration;
import java.time.LocalDateTime;

public class SpringFestivalCountdown2 {
    public static void main(String[] args) {
        //计算现在距离今年大年初一还有多少天，多少小时，多少分钟，多少秒？
        //现在时间：2025-8-4 15:30:00
        //过年时间：2026-2-17 00:00:00
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime newYear = LocalDateTime.of(2026, 1, 22, 0, 0, 0);

        //计算时间间隔
        Duration duration = Duration.between(now, newYear);
        long totalSec = duration.getSeconds();

        long days = totalSec / (24 * 60 * 60);//天数
        long hours = (totalSec % (24 * 60 * 60)) / (60 * 60);// 小时
        long minutes = (totalSec % (60 * 60)) / 60;// 分钟
        long seconds = totalSec % 60;

        System.out.println("距离2026年2月17日还有：" + days + " 天" + hours + " 小时" + minutes + " 分钟" + seconds + " 秒");
    }
}
